package iotwisp.school.user.entity;

import java.util.List;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.ManyToMany;
import javax.persistence.Table;
import javax.persistence.Transient;

import iotwisp.base.tree.TreeDataBaseEntity;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.Type;

import iotwisp.school.user.qo.PermissionQO;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * {@link PermissionQO} {@link diance.view.organization.vo.PermissionVO}
 * {@link diance.view.organization.provider.qo.PermissionViewQO}
 * {@link jzjd.organization.service.PermissionService} {@link PermissionSPI}
 * Permission PermissionQO PermissionVO PermissionSPI PermissionViewSPI
 * PermissionService PermissionViewService PermissionController
 * PermissionViewController
 *
 * @author yuxx
 */
@Data
@EqualsAndHashCode(callSuper = false)
@DynamicUpdate
@Entity
@Table(name = M.TABLE_PREFIX + "permission")
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@SuppressWarnings("serial")
public class Permission extends TreeDataBaseEntity {

	/**
	 * 功能权限名称
	 */
	@Column(name = "name")
	private String name;

	@Column(name = "description", length = 512)
	private String description;
	
	/**
	 * 是否已删除
	 */
	@Type(type = "yes_no")
	@Column(name = "remove")
	private Boolean remove;

	/**
	 * 归属的角色集
	 */
	@ManyToMany(mappedBy = "permissionSet", fetch = FetchType.LAZY)
	private Set<Role> roleSet;

	@Transient
	private List<Permission> children;
}
